import org.openjdk.jol.info.ClassLayout;

public class T13
{
    public static void main(String[] args) throws InterruptedException
    {
        Thread.sleep(5000);

        Object o = new Object();
        new Thread(() -> {
            synchronized (o) {
                System.out.println("child:" + ClassLayout.parseInstance(o).toPrintable());
                /**
                 *  OFFSET  SIZE   TYPE DESCRIPTION                               VALUE
                 *       0     4        (object header)                           ca f1 12 20 (11001010 11110001 00010010 00100000) (538112458)
                 *       4     4        (object header)                           00 00 00 00 (00000000 00000000 00000000 00000000) (0)
                 *       8     4        (object header)                           e5 01 00 f8 (11100101 00000001 00000000 11111000) (-134217243)
                 *      12     4        (loss due to the next object alignment)
                 * Instance size: 16 bytes
                 * Space losses: 0 bytes internal + 4 bytes external = 4 bytes total
                 */
            }
        }).start();

        synchronized (o) {
            // main - 偏向锁 - 轻量级锁CAS - 重量级锁
            System.out.println("main:" + ClassLayout.parseInstance(o).toPrintable());
            /**
             *  OFFSET  SIZE   TYPE DESCRIPTION                               VALUE
             *       0     4        (object header)                           ca f1 12 20 (11001010 11110001 00010010 00100000) (538112458)
             *       4     4        (object header)                           00 00 00 00 (00000000 00000000 00000000 00000000) (0)
             *       8     4        (object header)                           e5 01 00 f8 (11100101 00000001 00000000 11111000) (-134217243)
             *      12     4        (loss due to the next object alignment)
             * Instance size: 16 bytes
             * Space losses: 0 bytes internal + 4 bytes external = 4 bytes total
             */
        }
    }
}
